package main

import (
	"time"
	"fmt"
	"strconv"
)


func sample(ch chan string){
	for i:=0;i<20;i++{
		ch <- "i got message "+strconv.Itoa(i)
		time.Sleep(2*time.Second)
	}
}

func sample2(ch chan int){
	for i:=0;i<20;i++{
		ch <- i
		time.Sleep(1*time.Second)
	}
}

func main() {
	s1 := make(chan string,5)
	s2 := make(chan int,5)

	for i:=0;i<10;i++{
		go sample(s1)
		go sample2(s2)
	}

	for {
		select {
		case str, ok := <-s1:
			if ok {
				fmt.Println(str)
			}
		case str1, ok1 := <-s2:
			if ok1 {
				fmt.Println(str1)
			}
		}
	}
}
